Skip to content

feat: One weight IS↔SP variants, fix complexity metadata, enrich paper#106

Merged
GiggleLiu merged 3 commits intomainfrom
feat/one-weight-variant-and-cleanup
Feb 28, 2026
Merged

feat: One weight IS↔SP variants, fix complexity metadata, enrich paper#106
GiggleLiu merged 3 commits intomainfrom
feat/one-weight-variant-and-cleanup

Conversation

@GiggleLiu
Copy link
Contributor

@GiggleLiu GiggleLiu commented Feb 28, 2026

Summary

  • Add One weight variant for MaximumIndependentSet ↔ MaximumSetPacking reductions
  • Remove dead APIs: ConfigIterator, unused testing module, LinearConstraint::new() publicity
  • Fix 7 wrong declare_variants! complexity strings (poly-time problems had exponential bounds)
  • Fix 4 wrong #[reduction(overhead)] formulas (universe mismatch, quadratic edges, cell counts)
  • Re-export reduction_graph.json with corrected data
  • Remove standalone complexity table from paper; show complexity inline via render-complexity
  • Enrich all 21 problem definitions with algorithm context, limitations, and citations

Test plan

  • All 1628 tests pass (cargo test)
  • Clippy clean
  • Paper compiles with no warnings (typst compile)
  • Reduction graph JSON regenerated with correct overheads

🤖 Generated with Claude Code

- Add One weight variant for MaximumIndependentSet ↔ MaximumSetPacking
  reductions using local macros to keep impls DRY
- Register MaximumSetPacking<One> variant and add One→i32 weight cast
- Remove ConfigIterator (superseded by DimsIterator)
- Remove unused testing module (macros never adopted)
- Make LinearConstraint::new() pub(crate) (only le/ge/eq delegate to it)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.88%. Comparing base (13249b3) to head (c24294a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #106      +/-   ##
==========================================
- Coverage   96.89%   96.88%   -0.02%     
==========================================
  Files         198      196       -2     
  Lines       26904    26747     -157     
==========================================
- Hits        26068    25913     -155     
+ Misses        836      834       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

… paper

Variant complexity fixes:
- MaximumMatching: 2^n → n^3 (polynomial by Edmonds' blossom)
- KColoring<K2>: 2^n → n+m (polynomial bipartiteness test)
- KColoring<K3>: 3^n → 1.3289^n (Beigel-Eppstein)
- KColoring<K4>: 4^n → 1.7159^n (Wu et al.)
- KColoring<K5>: 5^n → 2^n (Zamir)
- KColoring<KN>: k^n → 2^n (Björklund et al.)
- KSatisfiability<K2>: 2^n → n+m (Aspvall-Plass-Tarjan SCC)

Reduction overhead fixes:
- IS→SP: universe_size num_vertices → num_edges (sets contain edge indices)
- SP→IS: num_edges num_sets → num_sets^2 (intersection graph)
- SAT→kSAT: tighter clause/variable bounds for short-clause padding
- Factoring→CircuitSAT: 6 assignments + I/O vars per multiplier cell

Paper: remove standalone complexity table (Section 2.6), add
render-complexity inline in problem-def, enrich all 21 definitions
with algorithm context, limitations, and citations verified via
web search. Fix MaxClique bound (1.1892→1.1996 via MIS complement).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@GiggleLiu GiggleLiu changed the title feat: add One weight variant for IS↔SP reductions and cleanup feat: One weight IS↔SP variants, fix complexity metadata, enrich paper Feb 28, 2026
@GiggleLiu GiggleLiu requested a review from Copilot February 28, 2026 03:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the reduction/variant metadata system by adding a unit-weight (One) variant for the MaximumIndependentSet ↔ MaximumSetPacking reductions, correcting complexity/overhead metadata used to generate the reduction graph and paper, and removing unused/dead testing/config APIs.

Changes:

  • Add One weight variants for MIS ↔ Set Packing reductions and variant-cast support for MaximumSetPacking.
  • Fix/refresh complexity + reduction-overhead metadata and regenerate reduction_graph.json; render complexity inline in the paper.
  • Remove dead APIs and test utilities (testing module, ConfigIterator) and update unit tests accordingly.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/unit_tests/testing/mod.rs Removes tests for the deleted testing utilities module.
src/unit_tests/testing/macros.rs Removes macro tests for deleted testing macros.
src/unit_tests/rules/maximumindependentset_maximumsetpacking.rs Adds closed-loop tests for One-weighted MIS ↔ SP reductions.
src/unit_tests/config.rs Removes tests tied to deleted ConfigIterator; keeps conversion + dims iterator tests.
src/testing/mod.rs Deletes the public testing utilities module (macros + test-case structs).
src/testing/macros.rs Deletes exported testing macros (graph_problem_tests!, complement_test!, quick_problem_test!).
src/rules/sat_ksat.rs Updates #[reduction(overhead)] formulas for SAT → 3-SAT transformation.
src/rules/maximumsetpacking_casts.rs Adds variant-cast reduction MaximumSetPacking<One> => MaximumSetPacking<i32>.
src/rules/maximumindependentset_maximumsetpacking.rs Generalizes MIS ↔ SP reductions to support both i32 and One; fixes overhead field mapping.
src/rules/factoring_circuit.rs Updates reduction overhead metadata for Factoring → CircuitSAT.
src/models/set/maximum_set_packing.rs Declares MaximumSetPacking<One> variant complexity.
src/models/satisfiability/ksat.rs Fixes K2 (2-SAT) declared complexity to polynomial time.
src/models/optimization/ilp.rs Makes LinearConstraint::new crate-private.
src/models/graph/maximum_matching.rs Fixes declared complexity to polynomial time (n^3).
src/models/graph/kcoloring.rs Updates declared complexities for K-coloring variants.
src/lib.rs Removes pub mod testing export.
src/config.rs Removes ConfigIterator and tightens module docs around DimsIterator.
docs/src/reductions/reduction_graph.json Regenerates graph JSON with updated complexities, nodes/edges, and overhead formulas.
docs/paper/references.bib Adds citations supporting updated complexity claims.
docs/paper/reductions.typ Renders complexity inline from graph JSON; enriches problem definitions with algorithm context.
.claude/CLAUDE.md Documents how to verify declare_variants! complexity and #[reduction(overhead)] formulas.
Comments suppressed due to low confidence (1)

src/config.rs:6

  • ConfigIterator has been removed from the public config API. Even if it was unused internally, this is a breaking change for downstream users who relied on it for uniform-dimension iteration. If intentional, consider documenting the replacement (e.g., DimsIterator::new(vec![num_flavors; num_variables])) and accounting for the API break in versioning/release notes.
//! Configuration utilities for problem solving.

/// Convert a configuration index to a configuration vector.
///
/// The index is treated as a number in base `num_flavors`.
pub fn index_to_config(index: usize, num_variables: usize, num_flavors: usize) -> Vec<usize> {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

KColoring<K2, SimpleGraph> => "num_vertices + num_edges",
KColoring<K3, SimpleGraph> => "1.3289^num_vertices",
KColoring<K4, SimpleGraph> => "1.7159^num_vertices",
KColoring<K5, SimpleGraph> => "2^num_vertices",
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

KColoring<K5, SimpleGraph> is declared with complexity 2^num_vertices, but the paper text in docs/paper/reductions.typ states 5-coloring has an algorithm that breaks the 2^n barrier (Zamir 2021). To keep the rendered complexity (from declare_variants!) consistent with the paper and with the “best known algorithm” convention, update this complexity string (or adjust the paper text if you intentionally want an upper bound).

Suggested change
KColoring<K5, SimpleGraph> => "2^num_vertices",
KColoring<K5, SimpleGraph> => "<2^num_vertices",

Copilot uses AI. Check for mistakes.

#problem-def("KColoring")[
Given $G = (V, E)$ and $k$ colors, find $c: V -> {1, ..., k}$ minimizing $|{(u, v) in E : c(u) = c(v)}|$.
Deciding $k$-colorability is NP-complete for $k >= 3$ @garey1979. Best known: $O(n+m)$ for $k=2$ (equivalent to bipartiteness testing by BFS); $O^*(1.3289^n)$ for $k=3$ @beigel2005; $O^*(1.7159^n)$ for $k=4$ @wu2024; $O^*((2-epsilon)^n)$ for $k=5$, the first to break the $2^n$ barrier @zamir2021; $O^*(2^n)$ in general via inclusion-exclusion over independent sets @bjorklund2009.
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section claims 5-coloring runs in $O^*((2-\epsilon)^n)$, but the rendered complexity line for KColoring is sourced from reduction_graph.json / declare_variants! (currently KColoring<K5> is 2^num_vertices). Align the complexity metadata with this claim (or soften the claim) so the paper doesn’t present conflicting complexities.

Suggested change
Deciding $k$-colorability is NP-complete for $k >= 3$ @garey1979. Best known: $O(n+m)$ for $k=2$ (equivalent to bipartiteness testing by BFS); $O^*(1.3289^n)$ for $k=3$ @beigel2005; $O^*(1.7159^n)$ for $k=4$ @wu2024; $O^*((2-epsilon)^n)$ for $k=5$, the first to break the $2^n$ barrier @zamir2021; $O^*(2^n)$ in general via inclusion-exclusion over independent sets @bjorklund2009.
Deciding $k$-colorability is NP-complete for $k >= 3$ @garey1979. Best known upper bounds for deciding $k$-colorability include: $O(n+m)$ for $k=2$ (equivalent to bipartiteness testing by BFS); $O^*(1.3289^n)$ for $k=3$ @beigel2005; $O^*(1.7159^n)$ for $k=4$ @wu2024; $O^*(2^n)$ for $k >= 5$ via inclusion-exclusion over independent sets @bjorklund2009; and faster sub-$2^n$ algorithms are known for $k=5$ @zamir2021.

Copilot uses AI. Check for mistakes.
Comment on lines 20 to 30
pub mod config;
pub mod error;
pub mod export;
pub(crate) mod expr;
pub mod io;
pub mod models;
pub mod registry;
pub mod rules;
pub mod solvers;
pub mod testing;
pub mod topology;
pub mod traits;
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing pub mod testing; is a breaking public API change (downstream users can no longer import problemreductions::testing / its macros). If this is intentional, consider documenting it in release notes and ensuring the versioning strategy accounts for the break.

Copilot uses AI. Check for mistakes.
impl LinearConstraint {
/// Create a new linear constraint.
pub fn new(terms: Vec<(usize, f64)>, cmp: Comparison, rhs: f64) -> Self {
pub(crate) fn new(terms: Vec<(usize, f64)>, cmp: Comparison, rhs: f64) -> Self {
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing LinearConstraint::new from pub to pub(crate) is a breaking change for external users that constructed constraints via new. If the intent is to force callers onto le/ge/eq, consider noting this in release notes and (optionally) adding a doc comment/deprecation path to guide downstream migration.

Suggested change
pub(crate) fn new(terms: Vec<(usize, f64)>, cmp: Comparison, rhs: f64) -> Self {
pub fn new(terms: Vec<(usize, f64)>, cmp: Comparison, rhs: f64) -> Self {

Copilot uses AI. Check for mistakes.
num_variables = "num_bits_first * num_bits_second",
num_assignments = "num_bits_first * num_bits_second",
num_variables = "6 * num_bits_first * num_bits_second + num_bits_first + num_bits_second",
num_assignments = "6 * num_bits_first * num_bits_second",
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The num_assignments overhead doesn’t match what reduce_to() constructs. The reduction adds 6 assignments per multiplier cell plus one additional assignment per output bit constraint (loop over m_vars), i.e. num_bits_first + num_bits_second extra assignments. Update the overhead formula accordingly and regenerate docs/src/reductions/reduction_graph.json so the exported graph matches the code.

Suggested change
num_assignments = "6 * num_bits_first * num_bits_second",
num_assignments = "6 * num_bits_first * num_bits_second + num_bits_first + num_bits_second",

Copilot uses AI. Check for mistakes.
- Fix KColoring K5 complexity: "2^num_vertices" -> "(2-epsilon)^num_vertices" (Zamir 2021)
- Fix Factoring->CircuitSAT num_assignments overhead to include output bit constraints
- Add tests for MaximumSetPacking variant cast reductions (One->i32, i32->f64)
- Regenerate reduction_graph.json with corrected metadata

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@GiggleLiu GiggleLiu merged commit 1901a5f into main Feb 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants